import request from "@/utils/request"

const commonPath = "/admin/product";
const attr = {
  //获取一级分类列表  GET /admin/product/getCategory1
  getCategory1:function (){
    return request.get(`${commonPath}/getCategory1`)
  },

  //获取二级分类列表 GET /admin/product/getCategory2/{category1Id}
  getCategory2:function (category1Id){
    return request.get(`${commonPath}/getCategory2/${category1Id}`)
  },

  //获取三级分类列表 GET /admin/product/getCategory3/{category2Id}
  getCategory3:function (category2Id){
    return request.get(`${commonPath}/getCategory3/${category2Id}`)
  },

  //根据三级分类获取基础属性列表 GET /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
  getAttrInfoList:function ({category1Id,category2Id,category3Id}){
    return request.get(`${commonPath}/attrInfoList/${category1Id}/${category2Id}/${category3Id}`)
  },

  //新增属性 修改属性  POST /admin/product/saveAttrInfo
  addOrUpdateUpdateAttr(attr={}) {
    return request.post(`${commonPath}/saveAttrInfo`,{
      ...attr
    })
  },

  //删除属性 DELETE /admin/product/deleteAttr/{attrId}
  delAttr:function (attrId){
    return request.delete(`${commonPath}/deleteAttr/${attrId}`)
  },
}

export default attr
